#use strict;
use warnings;
use lib '/home/yasumoto/.cpanm/work/1312182090.2395/Path-Class-0.24/lib/';
use Plack::Request;
#use Plack::Response;
use Path::Class qw/dir file/;
use FindBin;
use Imager;
my $dir = $FindBin::Bin;

my $ppp = sub {
    my $env = shift;
#   my @sorted_key = sort keys %$env;
    my $req = Plack::Request->new( $env );
    my $path_info = $req->path_info;
    my $file = file( $dir, 'data', $path_info );
#   my $body = "Not Found $file $path_info \n";
    if ( -f $file ) {
	    my $img = Imager->new;
	    $img->read( file => "$file" )
		    or die $img->errstr;
        $img = $img->scale(
            xpixels => 60,
            ypixels => 60,
        );
        my $file2 = 'data/120x120/nya.jpg';
        our $data;
        $img->write(file => "$file2", 
                        data => \$data
                   )
        or die $img->errstr;
        $body = "Found $file $path_info \n \$dir is $dir \n\n ";
        $body .= $file->slurp; 
    }
    my $res = $req->new_response(200);
    $res->content_type( 'image/jpg' );
    $res->body( $data );
    return $res->finalize;
};
__END__
----
$ cd /home/user/labs/
$ plackup app.psgi

----
http://127.0.0.1:8090/hoge.txt

----
"/home/user/labs/data/hoge.txt"があれはそのな中身を返す

Found /home/user/labs/data/hoge.txt. /hoge.txt. 
